<!--包含头部文件-->
{include file="public/header" /}
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>采购中心
    <span class="c-gray en">&gt;</span> 商品库
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="row">
        <form action="?" method="get">
            <div class="col-md-2">
                商品分类：
                <span class="select-box inline">
		<select name="goods_cate" class="select goods_cate">
            <option value="0" {if condition="$gets['goods_cate'] == 0" } selected{/if}>综合</option>
            {volist name="item_cates" id="vo"}
			<option value="{$vo.id}" {if condition="$vo['id'] == $gets['goods_cate']" } selected{/if}>{$vo.name}</option>
            {/volist}
		</select>
		</span>
            </div>
            <div class="col-md-3">
                券后价格：
                <input type="text" name="min_price" id="min_price" value="{$gets.min_price|default=''}"
                       class="input-text" placeholder="最低价" style="width:100px;">
                -
                <input type="text" name="max_price" id="max_price" value="{$gets.max_price|default=''}"
                       class="input-text" placeholder="最高价" style="width:100px;">
            </div>
            <div class="col-md-2">
                排序：
                <span class="select-box inline">
		<select name="sort" class="select sort">
            <option value="0" {if condition="$gets['sort'] == 0" } selected{/if}>最新</option>
			<option value="1" {if condition="$gets['sort'] == 1" } selected{/if}>券后价（低到高）</option>
			<option value="2" {if condition="$gets['sort'] == 2" } selected{/if}>券后价（高到低）</option>
			<option value="3" {if condition="$gets['sort'] == 3" } selected{/if}>券面额</option>
			<option value="4" {if condition="$gets['sort'] == 4" } selected{/if}>销量</option>
			<option value="5" {if condition="$gets['sort'] == 5" } selected{/if}>拥金比例</option>
		</select>
		</span>
            </div>
            <div class="col-md-2">
                销量：
                <input type="text" name="sales_volume" id="sales_volume" value="{$gets.sales_volume|default=''}"
                       placeholder=" 销量" style="width:100px" class="input-text">
            </div>
            <button class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 筛选</button>
        </form>
    </div>
    <div class="wrapper" style="margin-top: 20px">
        <div class="goods-list clearfix">
            {volist name='data' id='vo'}
            <div id="goods-items_5196187" data_goodsid="551683156716" data-sellerid="2786638235" class="goods-item ">
                <div class="goods-item-content">
                    <div class="goods-img">
                        <a href="javascript:"
                           onclick="goods_purchase('采购单','{$vo.shoptype}','{$vo.itemid}','{$vo.fqcat}','1000','700','{$vo.activityid}','{$vo.couponmoney}')"
                           tppabs="http://www.dataoke.com/item?id=5196187">
                            <img class="lazy" src="{$vo.itempic}"
                                 tppabs="http://p1static.dataoke.com/web/images/download.gif"
                                 data-original="{$vo.itempic}">
                        </a>
                    </div>
                    <div class="goods-info">
										<span class="goods-tit">
											<a href="javascript:"
                                               onclick="goods_purchase('采购单','{$vo.shoptype}','{$vo.itemid}','{$vo.fqcat}','1000','700','{$vo.activityid}','{$vo.couponmoney}')"
                                               tppabs="http://www.dataoke.com/item?id=5196187" target="_blank">
												{$vo.itemtitle}											</a>
										</span>
                        <div class="goods-slider">
                            <span class="slider"><em data-width="0%"></em></span>
                        </div>
                        <div class="goods-qjy">
                            <div class="goods-price"><span>券后价</span>
                                <p><b style="color: red"><i class="rmb-style">￥</i>{$vo.itemendprice}</b></p></div>
                            <div class="goods-yj" title="佣金 7.16 元">
                                <span>{$vo.tktype}</span>
                                <p>{$vo.tkrates}<b>%</b></p>
                            </div>
                        </div>
                        <div class="goods-sale clearfix">
                            <div class="goods-quan fl"><p>券<b><i class="rmb-style">￥</i>{$vo.couponmoney}</b></p></div>
                            <span class="fl">销量<b>{$vo.itemsale}</b></span>
                            {if condition="$vo['shoptype'] == 'B'"}
                            <div class="tmall clearfix">
                                <i class="tag-tmall"></i>
                            </div>
                            {else /}
                            <div class="taobao clearfix">
                                <i class="tag-tmall"></i>
                            </div>
                            {/if}

                        </div>
                    </div>
                </div>
            </div>
            {/volist}
        </div>
    </div>

</div>
<!--包含footer文件-->
{include file="public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script src="__STATIC__/js/dropload.min.js"></script>

<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*采购单*/
    function goods_purchase(title, user_type, id,item_cate, w, h,activityid,couponmoney) {
        var new_url =  '/admin/goods/add_goods/id/'+id+'/user_type/'+user_type+'/item_cate/'+item_cate+'/activityid/'+activityid+'/couponmoney/'+couponmoney;
        layer_show(title, new_url, w, h);
    }
    $(function () {
        page = {$next_page};
        var goods_cate = $('.goods_cate  option:selected').val();
        var sort = $('.sort  option:selected').val();
        var min_price = $('#min_price').val();
        var max_price = $('#max_price').val();
        var sales_volume = $('#sales_volume').val();

        // dropload
        var dropload = $('.wrapper').dropload({
            scrollArea : window,
            // autoLoad:true,
            threshold : '1000',                                                      // 提前加载距离
            domDown : {
                domClass   : 'dropload-down',
                domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
                domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                domNoData  : '<div class="dropload-noData">暂无数据</div>'
            },
            loadDownFn : function(me){
                $.ajax({
                    type: 'GET',
                    url: "{:url('goods/ajax_goods')}",
                    data: {"goods_cate":goods_cate,"sort":sort,"min_price":min_price,"max_price":max_price,"sales_volume":sales_volume,"page":page},
                    dataType: 'json',
                    success: function(data){
                        var html='';
                        for(var i = 0; i < data.data.length; i++){
                            if (data.data[i].shoptype == 'B'){
                                var str = '<div class="tmall clearfix">'
                            }else {
                                var str = '<div class="taobao clearfix">'
                            }
                            html += '<div id="goods-items_5196187" data_goodsid="'+data.data[i].itemid+'" data-sellerid="2786638235" class="goods-item ">' +
                                '<div class="goods-item-content">'+
                                '<div class="goods-img">'+
                                '<a href="javascript:" onclick="' +
                                "goods_purchase('采购单','"+data.data[i].shoptype+"','"+data.data[i].itemid+"','"+data.data[i].fqcat+"','1000','700')" +
                                '" >' +
                                ' <img class="lazy" src="'+data.data[i].itempic+'" tppabs="http://p1static.dataoke.com/web/images/download.gif" data-original="'+data.data[i].itempic+'">'+
                                '</a>'+
                                '</div>'+
                                '<div class="goods-info">'+
                                '<span class="goods-tit">'+
                                '<a href="javascript:if(confirm(\'\'))window.location=\'http://www.dataoke.com/item?id=5202259\'"'+
                                'tppabs="http://www.dataoke.com/item?id=5196187" target="_blank">'+data.data[i].itemtitle+'</a>'+
                                ' </span>'+
                                '<div class="goods-slider">'+
                                '<span class="slider"><em data-width="0%"></em></span>'+
                                '</div>'+
                                '<div class="goods-qjy">'+
                                '<div class="goods-price"><span>券后价</span>'+
                                '<p><b style="color: red"><i class="rmb-style">￥</i>'+data.data[i].itemendprice+'</b></p></div>'+
                                ' <div class="goods-yj" title="佣金 7.16 元">'+
                                '<span>'+data.data[i].tktype+'</span>'+
                                '<p>'+data.data[i].tkrates+'<b>%</b></p>'+
                                '</div>'+
                                ' </div>'+
                                '<div class="goods-sale clearfix">'+
                                ' <div class="goods-quan fl"><p>券<b><i class="rmb-style">￥</i>'+data.data[i].couponmoney+'</b></p></div>'+
                                ' <span class="fl">销量<b>'+data.data[i].itemsale+'</b></span>'+ str +
                                '<i class="tag-tmall"></i>'+
                                '</div>'+
                                '</div> </div> </div> </div>';
                            page = data.min_id
                        }
                        // 为了测试，延迟1秒加载
                        setTimeout(function(){
                            $(".goods-list").append(html);
                            // 每次数据加载完，必须重置
                            dropload.resetload();
                        },500);
                    },
                    error: function(xhr, type){
                        alert('数据请求错误!');
                        // 即使加载出错，也得重置
                        dropload.resetload();
                    }
                });
            }
        });
    })

</script>
</body>
</html>